<?php
/**
 * 
 */
class FoodPlaceRecord extends TActiveRecord
{
	const TABLE='tbl_food_place';

	public $ID;
	public $Name;	
	public $Highlights;
	public $Status=0;	
	public $Location;
	public $NearestMRT;
	public $OperatingHours;
	public $OpenUntil;
	public $PriceRange;	
	public $MainPhoto;			
	public $Contact;		
	public $PlaceDetails;
	public $MapGoogle;
	public $IsRecommended=0;
	public $IsNew=0;
	public $CreateBy;
	public $ModifyBy;
	public $CreateDate=0;
	public $ModifyDate=0;
	public $CssClass;
	
	public static $COLUMN_MAPPING=array
	(
		'food_place_id'=>'ID',
		'name'=>'Name',
		'highlights'=>'Highlights',
		'status'=>'Status',
		'location'=>'Location',
		'nearest_mrt'=>'NearestMRT',
		'operating_hours'=>'OperatingHours',
		'open_until'=>'OpenUntil',
		'price_range'=>'PriceRange',				
		'thumb_photo'=>'MainPhoto',									
		'contact'=>'Contact',			
		'place_details'=>'PlaceDetails',
		'map_google'=>'MapGoogle',
		'is_recommended'=>'IsRecommended',
		'is_new'=>'IsNew',
		'c_by'=>'CreateBy',
		'm_by'=>'ModifyBy',
		'c_date'=>'CreateDate',
		'm_date'=>'ModifyDate'
	);

	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
	
	public function save()
	{
		if ($this->ID <= 0)
		{
			$this->CreateDate = time();
		}
		$this->ModifyDate = time();
		parent::save();
	}
	
	public function getAllItems()
	{
		$criteria = new TActiveRecordCriteria;
		$criteria->Condition = "food_place_id > 0";
		return self::finder()->findAll($criteria);
	}
}
?>